<style>
.business_selected{opacity:0.5;filter:Alpha(opacity=50);margin-bottom: 50px;border: 3px solid green;border-radius: 25px;padding: 10px;
}
.business_no_selected{margin-bottom: 50px;border: 3px solid gray;border-radius: 25px;padding: 10px;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
if(<?php echo $amount;?> >0){
        $('#checkBussiness .row-form input[type=checkbox]').each(function() {
			$(this).parent().parent().addClass('business_no_selected');
		});
		$('#checkBussiness .row-form input[type=checkbox]').click(function(){
			var selected = [];
			var i = 0;
			$('#checkBussiness .row-form input[type=checkbox]').each(function() {
				   if ($(this).attr('checked')) {
				        i+=1;
						$(this).parent().parent().addClass('business_selected');
						$(this).parent().parent().removeClass('business_no_selected');
					    selected.push($(this).attr('name'));
				   }else{
						$(this).parent().parent().addClass('business_no_selected');
						$(this).parent().parent().removeClass('business_selected');
				   }
			   });
			$('#checkBussiness .row-form input:not(:checked)').each(function() {
				$(this).attr( "disabled", false);
			});   
			if(selected.length >= <?php echo $amount;?>){
			alert('Vous avez sélectionné votre maximum de cartes autorisées!');
				$('#checkBussiness .row-form input:not(:checked)').each(function() {
					$(this).attr( "disabled", true);
				});
			}
			$('#UserNumSelect').val(i);
			$('#UserIdAward').val(selected);
		});	
	}else{
			$('#checkBussiness .row-form input:not(:checked)').each(function() {
					$(this).attr( "disabled", true);
				});
	}
});
</script>
<div class="page-header">
	<div class="icon">
		<span class="ico-arrow-right"></span>
	</div>
	<h1><?php echo __('Sélection de vos cartes cadeaux'); ?></h1>
</div>        
<?php
echo $this->Form->create('Pages', array(
	'class' => 'validate',
	'action' => 'send',
	'type' => 'post',
	'inputDefaults' => array('label' => false, 'div' => false)));
?>         
<div class="row-fluid">
	<?php echo $this->Session->flash(); ?>
</div>

<div class="row-fluid">
<?php foreach($businesses as $business):?>
	<div class="span6">                
		<div class="block" style="margin-bottom:50px;">                                      
			<div class="data-fluid" id="checkBussiness">
				<div class="row-form clearfix">
					<div style="float:left; width: 120px;font-weight:bold;"><?php echo __('Business name'); ?>:</div>
					<div style="float:left;">
						<?php echo $business['Business']['name'];?>
					</div>
				</div>
				<div class="row-form clearfix">
					<div style="float:left; width: 120px;font-weight:bold;"><?php echo __('Value'); ?>:</div>
					<div style="float:left;">
						<?php echo $business['Business']['value'];?>
					</div>
				</div>
				<div class="row-form clearfix">
					<div style="float:left; width: 120px;font-weight:bold;"><?php echo __('Picture'); ?>:</div>
					<div style="float:left;">
						<?php
						if(($business['Business']['picture']!=null)&&(file_exists('files/business/thumbs/'.$business['Business']['picture']))){
						?>
						<img src="/files/business/thumbs/<?php echo $business['Business']['picture'];?>" />	
					<?php }?>
					</div>
				</div>
				<div class="row-form clearfix">
					<div style="float:left; width: 120px;font-weight:bold;"><?php echo __('Description'); ?>:</div>
					<div style="float:left;">
						<?php echo $business['Business']['description'];?>
					</div>
				</div>
				<div class="row-form clearfix">
					  <input type="checkbox" name ="<?php echo $business['Business']['id'];?>" value="<?php echo $business['Business']['id'];?>"> Cochez pour sélectionner
				</div>
			</div>
		</div>
	</div>
	
<?php endforeach;?>
</div>
<?php if($amount>0){?>
<div class="row-fluid">
	<div class="span8">                
		<div class="block">                                      
			<div class="data-fluid">
			    <div class="row-form clearfix">
					<div style="float:left; width: 120px;"><?php echo __('Last name'); ?>:</div>
					<div style="float:left;">
						<?php
						echo $this->Form->input('User.last_name', array('type' => 'text'));
						?>  
					</div>
				</div>
				<div class="row-form clearfix">
					<div style="float:left; width: 120px;"><?php echo __('First name'); ?>:</div>
					<div style="float:left;">
						<?php
						echo $this->Form->input('User.first_name', array('type' => 'text'));
						?>  
					</div>
				</div>
				<div class="row-form clearfix">
					<div style="float:left; width: 120px;"><?php echo __('Address delivery'); ?>:</div>
					<div style="float:left;">
						<?php
						echo $this->Form->input('User.address_delivery', array('type' => 'text'));
						echo $this->Form->input('User.id_award', array('type' => 'text','type'=>'hidden'));
						echo $this->Form->input('User.num_select', array('type' => 'text','type'=>'hidden'));
						?>
					</div>
				</div>
				<div class="row-form clearfix">
					<div style="float:left; width: 120px;"><?php echo __('Town'); ?>:</div>
					<div style="float:left;">
						<?php
						echo $this->Form->input('User.town', array('type' => 'text'));
						?>  
					</div>
				</div>
				<div class="row-form clearfix">
					<div style="float:left; width: 120px;"><?php echo __('Zip code'); ?>:</div>
					<div style="float:left;">
						<?php
						echo $this->Form->input('User.zipcode', array('type' => 'text'));
						?>  
					</div>
				</div>
				<div class="row-form clearfix">
					<div style="float:left; width: 120px;"><?php echo __('Phone'); ?>:</div>
					<div style="float:left;">
						<?php
						echo $this->Form->input('User.phone', array('type' => 'text'));
						?>
					</div>
				</div>
				<div class="row-form clearfix">
				<div style="float:left; width: 120px;"><?php echo __('Email'); ?>:</div>
				<div style="float:left;">
					<?php
					echo $this->Form->input('User.email', array('type' => 'text'));
					?>  
				</div>
			</div>
			</div>
		</div>
	</div>
	<div class="span11">
		<div class="span6">
			<div class="span3">&nbsp;</div>
			<div class="span9">
				<div class="btn-group ctr-container">
					<button class="btn btn-large btn-info" type="reset"><?php echo __('Reset'); ?></button>
					
					<button class="btn btn-large btn ctr-save" type="submit"><?php echo __('Submit'); ?></button>
					
				</div>
			</div>
		</div>
	</div>
</div>
<?php echo $this->Form->end(); ?>
<?php }?>
<style type="text/css">
	#container{
		max-width: 900px;
		margin: 0 auto;
	}
</style>